<!--suppress ALL -->
<template>
	<view class="form">
		<view class="formINFO" ref="HotWork">
<!--			<base-form v-model="formModel" :labelWidth="100" :formList="formList" :btnMessage="btnMessage"-->
<!--				@submit="submit" v-if='pageCheck === 0'>-->
<!--			</base-form>-->
      <Form :type="pageTyep" @submit="submit" v-if='pageCheck === 0'></Form>
			<hazardousCheck v-if="pageCheck === 1 " @whbsSubmit="cardSubmit" :pageCheck="pageCheck"></hazardousCheck>
			<protectionCheck v-else-if="pageCheck === 2" :pageCheck="pageCheck" @grfhSubmit='grfh'></protectionCheck>
			<safetyCheck v-else-if="pageCheck === 3" :pageCheck="pageCheck" @aqcsSubmit='aqcs'></safetyCheck>
			<Gas v-else-if="pageCheck === 4" :pageCheck="pageCheck" @fzr="fzr" :pageTyep="pageTyep"></Gas>
      <Reviewer v-else-if="pageCheck === 5" :pageCheck="pageCheck" :form="form" :pageTyep="pageTyep"></Reviewer>
		</view>
	</view>
</template>

<script>
	import deptPick from "@/pages/Components/department";
	import {
		workHeaderAPI
	} from '@/api/public.js'
	import hazardousCheck from '../components/hazardousCheck/hazardousCheck'
	import protectionCheck from '../components/protectionCheck/protectionCheck'
	import safetyCheck from '../components/safetyCheck/safetyCheck'
	import Gas from '../components/gas/gas'
	import Reviewer from '../components/Reviewer/Reviewer'
	import Form from '@/pages/Components/formMessage/formMessage'

	export default {
		components: {
			deptPick,
			hazardousCheck,
			protectionCheck,
			safetyCheck,
			Gas,
      Reviewer,
      Form
		},
		data() {
			return {
				pageCheck: 0,
				pageTyep: 1,
				btnMessage: {
					state: false,
					cancels: '上一步',
					submit: '下一步',
				},
				formModel: {
					name: "",
					userPicker: "",
					datetime: "",
					picker: "",
				},
				formList: [],
        form:{
				  whbs:null,
          grfh:null,
          aqcs:null,
        },
			}
		},
		mounted() {
			this.getWorkHeader()
		},
		methods: {
			submit() {
				this.pageCheck++
			},
      fzr(val){
        console.log('签字页',val)
        // this.form={...val.value}
        this.form.qzy = val.value
        this.pageCheck = val.step
      },
			cardSubmit(val) {

        console.log(this.$refs.whbs)
        let msg = val.value.map((e)=>{
          return e.value
        })
        this.form.whbs = msg.toString()
				this.pageCheck = val.step
			},
			grfh(val) {
        console.log('个人防护(父)',val)
        let msg = val.value.map((e)=>{
          return e.value
        })
        this.form.grfh = msg.toString()
				this.pageCheck = val.step
			},
			aqcs(val) {
        console.log('安全措施(父)',val)
        let msg = val.value.map((e)=>{
          return e.value
        })
        this.form.aqcs = msg.toString()
				this.pageCheck = val.step
			},
      URL(val) {
        this.pageCheck = val
      },
			getWorkHeader() {
				workHeaderAPI(this.pageTyep).then((r) => {
					let data = JSON.parse(r.data.jsonwbnr)
					let msg = data.map((e) => {
						return {
							label: e.label,
							type: e.tagIcon,
							placeholder: e.placeholder
						}
					})
					this.formList = msg
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
	.form {
		height: 100vh;
		overflow-y: auto;

		background: #f6f6f6;

		.formINFO {
			border-radius: 8px;
			background: #FFF;
			padding: 0 45rpx;
			margin: 50rpx 30rpx;
		}
	}
</style>
